﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Protocol.party;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Protocol;

namespace Pixysoft.Weblications.Sango.Command.party
{
    partial class SangoPartyHandler
    {
        private const int party_list_pageindex = 0;

        public party_list party_list()
        {
            string userCode = SangoManager.Authentication();
            party_list response = ReflectionManager.CreatePojo<party_list>();
            response.Succeed = false;

            Entities.Usr_Partymember member = PartyDao.tryGetActiveMember(userCode);

            Entities.Usr_Party party = null;

            if (member != null)
            {
                party = PartyDao.tryGetActiveParty(member.Partyprimarycode);

                response.party = PartyFacade.ToParty(party);

                response.parties = PartyFacade.ToParties(PartyDao.getParties(member.Partyprimarycode, party_list_pageindex));
            }
            else
            {
                response.parties = PartyFacade.ToParties(PartyDao.getParties(party_list_pageindex));
            }

            response.Succeed = true;
            return response;
        }
    }

    public interface party_list : ISangoResponse
    {
        /// <summary>
        /// 军团列表
        /// </summary>
        List<party_party> parties { get;set;}

        /// <summary>
        /// 玩家所属军团
        /// </summary>
        party_party party { get;set;}
    }
}
